<template>
  <div class="side">
    <div class="regist">
      <el-row>
        <el-button type="primary" @click="createData" class="dakai">提交</el-button>
      </el-row>
    </div>
    <div style="width:100%;margin-top:10px;">
      <el-form :model="QuestionBankSet" label-position="right" ref="dataForm" label-width="180px">
        <el-form-item label="交卷后答案以及解析的显示">
          <el-radio-group v-model="QuestionBankSet.showStatus">
            <el-radio label="1"> 不显示</el-radio>
            <el-radio label="2">全部批阅完成后一起显示</el-radio>
            <el-radio label="3">交卷后显示答案和解析</el-radio>
          </el-radio-group>
        </el-form-item>
      </el-form>
    </div>
  </div>
</template>

<script>
  import {addQuestionBankSet, getQuestionBankSet} from '@/api/system/question_bank_set';
  import {getTenantId} from '@/utils/auth';

  export default {
    data() {
      return {
        QuestionBankSet: {
          showStatus: ''
        }
      }
    },
    created() {
      this.fetchData()
    },
    methods: {
      fetchData() {
        getQuestionBankSet(getTenantId()).then(response => {
          this.QuestionBankSet = response.data
        }).catch(err => {
          console.log(err)
        })
      },
      createData() {
        this.$refs['dataForm'].validate((valid) => {
          if (valid) {
            this.QuestionBankSet.tenantId = getTenantId();
            addQuestionBankSet(this.QuestionBankSet).then(() => {
              this.$notify({
                title: '成功',
                message: '创建成功',
                type: 'success',
                duration: 2000
              });
              this.fetchData();
            })
          }
        })
      }
    }
  }
</script>

<style>
  .regist {
    width: 100%;
    height: 44px;
    line-height: 44px;
    background-color: #e7e9ed;
    padding-top: 15px;
    padding-right: 34px;
    margin-left: 0px;
  }

  .dakai {
    float: right;
    position: absolute;
    right: 10px;
    bottom: -25px;
  }
</style>
